import select

def deal(s1,s2):
    while True:
        r,w,e = select.select([s1,s2],[],[])
        if s1 in r:
            try:
                s = s1.recv(65536)
            except:
                s2.close()
                return
            if not s:
                s2.close()
                return
            try:
                s2.sendall(s)
            except:
                s1.close()
                return
            
        if s2 in r:
            try:    
                s = s2.recv(65536)
            except:
                s1.close()
                return
                
            if not s:
                s1.close()
                return
            try:
                s1.sendall(s)
            except:
                s2.close()